[extern irq_handler]

%macro IRQ 1
	[global irq%1]
	irq%1:
		cli
		push 0x0
		push %1
		jmp irq_stub_handler
%endmacro

IRQ 1
IRQ 2
IRQ 3
IRQ 4
IRQ 5
IRQ 6
IRQ 7
IRQ 8
IRQ 9
IRQ 10
IRQ 11
IRQ 12
IRQ 13
IRQ 14
IRQ 15

irq_stub_handler:
	pusha
	push ds
	push es
	push fs
	push gs
	mov ax, 0x10  ; Load the Kernel Data Segment descriptor!
	mov ds, ax
	mov es, ax
	mov fs, ax
	mov gs, ax
	mov eax, esp
	push eax
	mov eax, irq_handler
	call [eax]       ; A special call, preserves the 'eip' register
	pop eax
	pop gs
	pop fs
	pop es
	pop ds
	popa
	add esp, 0x8
	iret

